<%@page language="java" contentType="text/html; charset=UTF-8" isELIgnored="false" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="html" tagdir="/WEB-INF/tags" %>
<!DOCTYPE html>
<html>
<html:header title="单号规则编辑">

    <link rel="stylesheet" href="${baseUrl}css/public.css" media="all">
    <style type="text/css">
        .readonly{
            background-color: #eeeeee;
        }
    </style>
    <script>
        jQuery(function () {
            get("${baseUrl}sett/orderRule/getById.action?id=${id}", function (res) {
                if (res.code == 1){
                    let data = res.data;
                    data.example = data.prefix + getYYYYMMDD() + preFillZero(1, data.num);
                    formSetVal('orderRule',data);
                } else {
                    errTip(res.msg);
                }
            });
        });

        layui.use(['form', 'table'], function () {
            var $ = layui.jquery,
                form = layui.form,
                table = layui.table;

            form.on('submit(save)', function (data) {
                if (data.field.num == "") {
                    tip("编号位数不能为空");
                    return false;
                }
                if (data.field.prefix == "") {
                    tip("编号前缀不能为空");
                    return false;
                }

                console.log(JSON.stringify(data.field));
                delete data.field.name;
                delete data.field.example;
                tipLoad("更新中");
                post("${baseUrl}sett/orderRule/update.action", data.field,function (resp) {
                    closeLoading();
                    if (resp.code == 1) {
                        tip("保存成功");
                        refreshMainIframe("${baseUrl}sett/orderRule.action");
                        closeSubIframe();
                    } else {
                        tip(resp.msg);
                    }
                });

                return false;
            });

            form.on('submit(cancel)', function (data) {
                closeSubIframe();
                return false;
            });

        });
    </script>

</html:header>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">
        <form class="layui-form" action="" lay-filter="orderRule">
            <input type="hidden" name="id" value="${id}">
            <input type="hidden" name="type">

            <div class="layui-form-item">
                <label class="layui-form-label">编号类型</label>
                <div class="layui-input-inline">
                    <input type="text" name="name" readonly autocomplete="off" class="layui-input readonly">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">编号样例</label>
                <div class="layui-input-inline">
                    <input type="text" name="example" readonly autocomplete="off" class="layui-input readonly">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">编号前缀</label>
                <div class="layui-input-inline">
                    <input type="text" name="prefix" autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">编号位数</label>
                <div class="layui-input-inline">
                    <input type="text" name="num" autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">当前编号</label>
                <div class="layui-input-inline">
                    <input type="text" name="current" readonly autocomplete="off" class="layui-input readonly">
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit lay-filter="save">保存</button>
                    <button class="layui-btn layui-btn-primary" lay-submit lay-filter="cancel">取消</button>
                </div>
            </div>
        </form>
    </div>
</div>

</body>
<html:loading/>

</html>